<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>粘性定位</title>
		<style>
			body {
				height: 5000px;
			}
			.nav {
				background-color: greenyellow;
				position: sticky;
				top: 0;
				width: 500px;
				height: 50px;
				margin: 100px auto;
			}
			
		</style>
	</head>
	<body>
		<div class="nav">我是上边的导航栏</div>
	</body>
</html>